package com;

import java.util.HashMap;
import java.util.Map.Entry;

public class ThreadPool {
	private HashMap<String, PublicThread> threadPool = new HashMap<String, PublicThread>();

	public void closeThreadPool() {
		synchronized (this) {
			for (Entry<String, PublicThread> element : threadPool.entrySet()) {
				element.getValue().close();
			}
			threadPool.clear();
		}
	}

	public void addThread(String id, PublicThread thread) {
		synchronized (this) {
			threadPool.put(id, thread);
		}
	}

	public void removeThread(String id) {
		synchronized (this) {
			threadPool.remove(id);
		}
	}
}
